<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>公司审核管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="Access-Control-Allow-Origin" content="*">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="icon" href="/favicon.ico">
    <link rel="stylesheet" href="/resources/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="/resources/css/public.css" media="all" />
    <link rel="stylesheet" href="/resources/layui_ext/dtree/dtree.css" media="all" />
    <link rel="stylesheet" href="/resources/layui_ext/dtree/font/dtreefont.css" media="all" />

</head>
<body class="childrenBody">
<!-- 查询条件开始 -->

<blockquote class="layui-elem-quote">
    <form action="" method="post" id="searchFrm" lay-filter="searchFrm" class="layui-form layui-form-pane">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">公司信息</label>
                <div class="layui-input-inline">
                    <input type="text" name="gpName"  autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">审核状态</label>
                <div class="layui-input-block">
                    <input type="radio" name="rtResult" value="0" title="待审核">
                    <input type="radio" name="rtResult" value="2" title="审核拒绝">
                    <input type="radio" name="rtResult" value="1" title="审核通过">
                    <input type="radio" name="rtResult" value="3" title="所有" checked="">
                </div>
            </div>
            <div class="layui-inline" style="text-align: center;">
                <button type="button" class="layui-btn" lay-submit="" lay-filter="doSearch"><span class="layui-icon layui-icon-search"></span>查询</button>
                <button type="reset" class="layui-btn layui-btn-warm"><span class="layui-icon layui-icon-refresh-1"></span>重置</button>
            </div>
        </div>

    </form>
</blockquote>
<!-- 查询条件结束-->


<!-- 数据表格开始 -->
<div>
    <table class="layui-hide" id="roleTable" lay-filter="roleTable"></table>

    <div id="roleRowBar" style="display: none;">

        <button type="button" lay-event="showCompanyPic" class="layui-btn layui-btn-sm"><span class="layui-icon layui-icon-picture"></span>营业执照</button>
        <button type="button" lay-event="passAudit" class="layui-btn layui-btn-sm"><span class="layui-icon layui-icon-auz"></span>通过审核</button>
        <button type="button" lay-event="refuseAudit" class="layui-btn layui-btn-danger"><span class="layui-icon layui-icon-close"></span>拒绝</button>

    </div>
</div>


<!-- 数据表格结束 -->


<!-- 添加和修改的弹出层开始 -->
<div style="display: none;padding: 5px" id="businessPicDiv">

    <div class="layui-show-lg-inline" align="center">
        <img lay-src="ccc.jpg" id="companypic" align="center">
    </div>

</div>
<!-- 添加和修改的弹出层结束 -->


<script type="text/javascript" src="/resources/layui/layui.js"></script>
<script type="text/javascript">
    layui.extend({
        dtree: '/resources/layui_ext/dtree/dtree'   // {/}的意思即代表采用自有路径，即不跟随 base 路径
    }).use(['jquery','form','table','layer','dtree','upload'],function(){
        var $=layui.jquery;
        var form=layui.form;
        var table=layui.table;
        var layer=layui.layer;
        var dtree = layui.dtree;
        //初始化富文本
        var editIndex ;//= layedit.build('content');
        //加载 数据
        var tableIns=table.render({
            elem: '#roleTable'
            ,url:'/requestInfo/loadAllAuditComapny'
            ,toolbar: '#roleToolBar' //开启头部工具栏，并为其绑定左侧模板
            ,title: '客户数据表'
            ,height:'full-120'
            ,page: true
            ,limit:3000
            ,limits:[3000]
            ,cols: [ [
                {field:'gpName', title:'公司名称',align:'center',width:'200'}
                ,{field:'gpShortname', title:'公司简称',align:'center',width:'150'}
                ,{field:'createUserAccount', title:'创建账号',align:'center',width:'150'}
                ,{field:'gpStatus', title:'审核状态',align:'center',width:'100',templet:function(d){
                        if(d.rtResult==1)
                            return '<font color=green>审核通过</font>';
                        else if(d.rtResult==2)
                            return '<font color=red>审核拒绝</font>';
                        else
                            return '<font color=black>待审核</font>';
                    }}
                ,{field:'gpPolicyAddr', title:'公司地址',align:'center',width:'250'}
                ,{field:'gpAddr', title:'详细地址',align:'center',width:'250'}
                ,{field:'socialCode', title:'征信码',align:'center',width:'200'}
                ,{field:'rtDate', title:'提及审核时间',align:'center',width:'200'}
                ,{fixed: 'right', title:'操作', toolbar: '#roleRowBar',align:'center',width:'350'}
            ] ]
        });

        layui.upload({
            url: '/oss/doFileUpload' //上传接口
            ,method: 'post'
            ,success: function(res){ //上传成功后的回调
                console.log(res)
            }
        });

        //模糊查询
        form.on("submit(doSearch)",function(data){
            tableIns.reload({
                where:data.field,
                page:{
                    curr:1
                }
            });
            return false;
        });

        $("#doReset").click(function () {

            $("#dataFrm")[0].reset();

        })
        //监听工具条的事件
        table.on("toolbar(roleTable)",function(obj){
            switch(obj.event){
                case 'add':
                    openAddLayer();
                    break;
            };
        });

        //监听行工具条的事件
        table.on("tool(roleTable)",function(obj){
            var data = obj.data; //获得当前行数据
            switch(obj.event){
                case 'showCompanyPic':
                    showCompanyPic(data);
                    break;
                case 'passAudit':
                    passAudit(data);
                    break;
                case 'refuseAudit':
                    refuseAudit(data);
                    break;
            };
        });

        var mainIndex;
        var url;

        //打开修改的弹出层
        function openUpdateRoleLayer(data){
            mainIndex=layer.open({
                type:1,
                content:$("#addOrUpdateDiv"),
                area:['800px','600px'],
                title:'修改角色',
                success:function(){

                    $("#dataFrm")[0].reset();
                    //装载新的数据
                    form.val("dataFrm",data);
                    url="/role/updateRole";
                }
            });
        }

        form.on("submit(doSubmit)",function(data) {
            $.post(url, data.field, function (res) {
                if (res.code == 200) {
                    tableIns.reload();
                }
                layer.msg(res.msg);
                layer.close(mainIndex);
            })
            return false;
        });
        form.on("submit(doCancel)",function(data) {

            layer.close(mainIndex);
            return false;
        });

        function showCompanyPic(data){
            mainIndex=layer.open({
                type:1,
                content:$("#businessPicDiv"),
                area:['800px','600px'],
                title:'查看营业执照',
                success:function(){

                    $("#companypic").attr("src","http://large-thumbnail-image.oss-cn-hangzhou.aliyuncs.com/" + data.gpLicense + ".jpg");
                    //装载新的数据
                    // form.val("chargeFrm",data);
                    //  url="/groupInfo/charge";
                }
            });
        }


        //
        function passAudit(data){

            layer.confirm('你确定要通过【'+data.gpName+'】的审核吗?', {icon: 3, title:'提示'}, function(index){
                data.rtResult = 1;
                $.post("/requestInfo/passRequest",data,function(res){
                    if(res.code==200){
                        tableIns.reload();
                    }
                    layer.msg(res.msg);
                })
                layer.close(index);
            });

        }

        function refuseAudit(data) {
            layer.confirm('你确定要拒绝【'+data.gpName+'】的审核吗?', {icon: 3, title:'提示'}, function(index){
                data.rtResult = 2;
                $.post("/requestInfo/passRequest",data,function(res){
                    if(res.code==200){
                        tableIns.reload();
                    }
                    layer.msg(res.msg);
                })
                layer.close(index);
            });
        }

    });
</script>

</body>
</html>